package com.nbsaas.boot.wms.rest.convert;

import com.nbsaas.boot.wms.data.entity.WarehouseCatalog;
import com.nbsaas.boot.wms.api.domain.request.WarehouseCatalogRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.wms.data.entity.WarehouseCatalog;

/**
 * 仓库请求对象转换成实体对象
 */

public class WarehouseCatalogEntityConvert implements Converter<WarehouseCatalog, WarehouseCatalogRequest> {

    @Override
    public WarehouseCatalog convert(WarehouseCatalogRequest source) {
        WarehouseCatalog result = new WarehouseCatalog();
        BeanDataUtils.copyProperties(source, result);
        if (source.getParent() != null) {
            WarehouseCatalog parent = new WarehouseCatalog();
            parent.setId(source.getParent());
            result.setParent(parent);
        }
        return result;
    }
}

